<template>
  <div class="doctorregister">
    <div class="container ">
        <h2 class="titleName">{{orgName}}</h2>
      <!-- 头部信息 -->
      <header>
        <Row>
            <Col :xs="24">
            <div class="margin-up-down">
                    <Select class="w-select" clearable v-model="inqConType" style="width:120px;" placeholder="项目分类">
                        <Option
                            v-for="item in projectlist"
                            :value="item.dictValue"
                            :key="item.dictValue"
                            style='text-align:center'
                        >{{item.dictName}}</Option>
                    </Select>
                </div>
                <div class="margin-up-down">
                    <Input
                        v-model.trim="Name"
                        placeholder="请输入项目名称检索"
                        style="width: 150px"
                        clearable
                    />
                </div>
            <div class="margin-up-down">
                <Button type="primary" icon="ios-search" @click="getSuperviseData(1)"></Button>
            </div>
            </Col>
        </Row>  
      </header>   
      <!-- 列表 -->
      <div class="list">
        <Table @on-selection-change="selectChange" :loading="tableLoading" border stripe :columns="columns1" :data="list"></Table>
      </div>
    </div>
    <!--分页器-->
    <div class="page">
      <Page :total="superviseListSize" :current='pageNo' :page-size="pageSize" show-total show-elevator @on-change="pageChange"/>
    </div>
  </div>
</template>
<script>
// 医生注册信息
import cookie from "@/utils/cookie.js";
import api from "@/api/commonApi";
import fourLevelLinkage from "@/components/fourLevelLinkage";
export default {
  components: {
    fourLevelLinkage
  },
  data() {
    return {
      tableLoading: false,
      hospitalId: null,
      orgName: null,
      superviseListSize: 0,
      Name: '',
      inqConType: '',
      projectlist:[
            {dictName: '全部', dictValue: 0},            
            {dictName: '健康咨询', dictValue: 1},            
            {dictName: '巡诊', dictValue: 2},            
            {dictName: '检查项目', dictValue: 3},            
            {dictName: '检验项目', dictValue: 4},            
            {dictName: '治疗项目', dictValue: 5},  
            {dictName: '其他', dictValue: " "},  
        ],
      list: [],
      pageNo: 1,
      pageSize: 10,
      columns1: [
        {title: "排序",key: "sum",width: 80,align: "center",
          render: (h, params) => {
              let sum = (this.pageNo-1)*this.pageSize + params.index +1;
              return h("span", sum);
          }
        },
        {title: "收费项目名称",key: "itemName",align: "center"},
        {title: "项目类别",key: "itemType",align: "center",
            render(h, params) {
                return ['', '巡诊', '健康咨询','检查','检验','治疗','其他'][params.row.itemType];
            }
        },
        {title: "物价编码",key: "itemCode",align: "center"},
        {title: "项目规格",key: "itemSpec",align: "center"},
        {title: "单位",key: "itemFeeUnitName",align: "center",},
        {title: "单价（元）",key: "itemFeePrice",align: "center",},
        {title: "HIS编码",key: "hisTechnologyCode",align: "center",},               
        {title: "HIS名称",key: "hisTechnologyName",align: "center",},               
        {title: "状态",key: "itemUsed",align: "center",
            render(h, params) {
                return ['禁用', '启动',][params.row.itemUsed];
            }
        }, 
      ],
    };
  },
  created() {
    this.hospitalId = this.$route.query.hospitalId
    this.orgName = this.$route.query.orgName
    let breadList = [
      { path: "/index", title: "首页" },
      {
        path: "/index/maintain/indexManagement/index",
        title: "索引管理"
      },
      {
        path: "/index/supervision/qualificationApply/list",
        title: "资质申请"
      }
    ];
    this.$emit("changeBreadList", breadList);
  },
  mounted() {
    let pageNo = this.$route.query.pageNo;
    if (pageNo) {
      this.pageNo = pageNo;
    }
    this.getSuperviseData(this.pageNo);
  },
  methods: {
    // 分页
    pageChange(index) {
      this.getSuperviseData(index);
    },
    // 获取页面数据
    getSuperviseData(pageNo) {
      if  (pageNo) {
        this.pageNo = Number(pageNo);
      }
      let params = {
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        // reviewStatus: 2,
      };
      params.hospitalId = this.hospitalId ? this.hospitalId : null;
      params.itemName = this.Name ? this.Name : null;
      params.itemType = this.inqConType ? this.inqConType : null;
      this.tableLoading = true;
      this.$axios.post(api.findSuperviseServiceItemChargeList, params).then(res => {
        if (res.data.code) {
          let ret = res.data.object;
          this.superviseListSize = ret.total;
          if(ret.records){
            ret.records.forEach((item, index) => {
              item.sum = this.addZeros(index);
            });           
            this.list = ret.records;
          } else {
            this.list = []
          }
        } else {
          this.$Message.info(res.data.message);
        }
        this.tableLoading = false;
      }).catch(() => {
        this.tableLoading = false;
      });
    }
  },
  watch: {
    'pageSize'(nv, ov) {
        this.getSuperviseData(this.pageNo)
    },
  }
};
</script>
<style lang="less" scoped>
.doctorregister {
  padding: 10px;
  width: 100%;
  background: #ffffff;
  box-sizing: border-box;
  margin: 0 auto;
  .margin-up-down {
        display: inline-block;
        margin: 10px 0;
    }
    .addButton{
      border: 1px solid #21c780;
      background-color: #21c780;
    }
  .container {
    width: 100%;
    margin: 0 auto;
    .titleName {
        text-align: center;
    }
    header {
      width: 100%;
      position: relative;
      .search{
        margin: 10px 0;
      }
      
    }
    .list {
      width: 100%;
      margin: 10px 0;
    }
  }
  .page{
      text-align: center;
    }
}
</style>